package com.shrct.businessprocess.common;

import org.eclipse.xtext.xbase.lib.DoubleExtensions;

@SuppressWarnings("all")
public class Container {
  public static Container put(final Double value) {
    Container _container = new Container(value);
    return _container;
  }
  
  public Container(final Double value) {
    this.value = value;
    this.remain = value;
  }
  
  private Double value;
  
  private Double remain;
  
  public Double getRemain() {
    return this.remain;
  }
  
  public Double take(final Double toTake) {
    Double _xblockexpression = null;
    {
      Double _xifexpression = null;
      boolean _lessEqualsThan = (this.remain.compareTo(toTake) <= 0);
      if (_lessEqualsThan) {
        _xifexpression = this.remain;
      } else {
        _xifexpression = toTake;
      }
      final Double actualTake = _xifexpression;
      double _minus = DoubleExtensions.operator_minus(this.remain, actualTake);
      this.remain = Double.valueOf(_minus);
      _xblockexpression = (actualTake);
    }
    return _xblockexpression;
  }
  
  public double taked() {
    double _minus = DoubleExtensions.operator_minus(
      this.value, this.remain);
    return _minus;
  }
  
  public Double takeIncremental(final Double toTake) {
    Double _xblockexpression = null;
    {
      double _taked = this.taked();
      final double actualTake = ((toTake).doubleValue() - _taked);
      Double _take = this.take(Double.valueOf(actualTake));
      _xblockexpression = (_take);
    }
    return _xblockexpression;
  }
}
